package com.sltx.util;

//import com.alibaba.dubbo.common.serialize.support.json.JsonObjectOutput;

import com.sltx.dataobject.entity.Entity;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created with IntelliJ IDEA.
 * User: tangzhen
 * Date: 16-10-27
 * Time: 上午10:29
 * To change this template use File | Settings | File Templates.
 */
public class BigDataUtils {


    public  static  String generateId(){
        String id = String.valueOf(UUID.randomUUID());
        return id;
    }

    /**
     * 按得分排序
     * @param list
     * @return
     */
    public static List<Entity> sortList(List<Entity> list){
        Collections.sort(list, new Comparator<Entity>() {
            @Override
            public int compare(Entity o1, Entity o2) {
                Integer n1 =o1.getScore();
                Integer n2 = o2.getScore();
                return n2.compareTo(n1);  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public boolean equals(Object obj) {
                return false;  //To change body of implemented methods use File | Settings | File Templates.
            }
        });
        return list;
    }

    /**
     * 按得分排序
     * @param list
     * @return
     */
    public static List<HashMap> sortMap(List<HashMap> list){
        Collections.sort(list, new Comparator<HashMap>() {
            @Override
            public int compare(HashMap o1, HashMap o2) {
                Integer n1 = Integer.parseInt(o1.get("SCORE").toString());
                Integer n2 = Integer.parseInt(o2.get("SCORE").toString());
                return n2.compareTo(n1);  //To change body of implemented methods use File | Settings | File Templates.
            }

            @Override
            public boolean equals(Object obj) {
                return false;  //To change body of implemented methods use File | Settings | File Templates.
            }
        });
        return list;
    }

    /**
     * 企业年报过滤原值
     * @return
     */
    public static JSONObject getEntAnnReport(JSONObject obj){

        if (obj == null){
            return null;
        }
        try{
            JSONArray asset = obj.getJSONArray("ASSET");
            JSONArray basic = obj.getJSONArray("BASIC");

            if (asset.size()>0){
                for (int i = 0;i < asset.size();i++){
                    JSONObject jsonObject =(JSONObject)asset.get(i);
                    jsonObject.put("MAIBUSINC_YZ","");
                    jsonObject.put("PROGRO_YZ","");
                    jsonObject.put("TOTEQU_YZ","");
                    jsonObject.put("VENDINC_YZ","");
                    jsonObject.put("RATGRO_YZ","");
                    jsonObject.put("ASSGRO_YZ","");
                    jsonObject.put("NETINC_YZ","");
                    jsonObject.put("LIAGRO_YZ","");
                }
            }
            if (basic.size()>0){
                for (int i = 0;i < basic.size();i++){
                    JSONObject jsonObject =(JSONObject)basic.get(i);
                    jsonObject.put("EMPNUM_YZ","");

                }
            }

        } catch (Exception e){
            e.printStackTrace();
            return null;
        }

        return obj;
    }

    /**
     * 农专年报过滤原值
     * @return
     */
    public static JSONObject getSFCAnnReport(JSONObject obj){


        if (obj == null){
            return null;
        }
        try{
            JSONArray asset = obj.getJSONArray("ASSET");


            if (asset.size()>0){
                for (int i = 0;i < asset.size();i++){
                    JSONObject jsonObject =(JSONObject)asset.get(i);
                    jsonObject.put("PRIYEASALES_YZ","");
                    jsonObject.put("PRIYEAPROFIT_YZ","");
                    jsonObject.put("RATGRO_YZ","");
                    jsonObject.put("PRIYEALOAN_YZ","");
                    jsonObject.put("PRIYEASUB_YZ","");
                }
            }


        } catch (Exception e){
            e.printStackTrace();
            return null;
        }

        return obj;

    }

    /**
     * 图谱分析
     * @param obj
     * @return
     */

    public static Map<String,Object> getStatistical(JSONObject obj){

        if (obj == null){
            return null;
        }
        Map<String, Object> resultMap = new HashMap<String, Object>();

        Map<String, Integer> industryCountMap = new HashMap<String, Integer>();
        Map<String, Integer> provinceCountMap = new HashMap<String, Integer>();
        int coreEntCount = 0 ;  //核心企业
        double capitalSum = 0 ; // 资产总量
        int newEnt = 0;         //新企业数量
        int personalCount = 0 ; //自然人数量
        int branchCount = 0 ;   //分支机构数量
        String province = "";   //主要发展地区
        String industry = "";   //主要产业领域
        int pri = 0 ;
        int in = 0;
        if(!obj.containsKey("ORDERINFO")){
    		return null;
    	}
        JSONObject resultdata = obj.getJSONObject("RESULTDATA");

        if (resultdata.size() > 0){
            try {

                JSONArray linksList = resultdata.getJSONArray("LINKS");
                JSONArray nodesList = resultdata.getJSONArray("NODES");


                for (int i = 0;i <nodesList.size();i++) {
                    JSONObject jsonObject = (JSONObject) nodesList.get(i);
                    if (jsonObject.get("TYPE").equals("GS")) {
                        coreEntCount++;


                        double dou = Double.parseDouble((String)jsonObject.getJSONObject("ATTIBUTEMAP").get("REGISTERED_CAPITAL"));
                        capitalSum+=dou;


                        Date date1 = new Date();
                        long time1 = date1.getTime();
                        long time0 = 1000 * 3600 * 24 * 365;
                        String strDate = (String) jsonObject.getJSONObject("ATTIBUTEMAP").get("ESDATE");
                        if (strDate != null && !"".equals(strDate)){
                            String replace = strDate.replaceAll("/", "-");
                            Date date = CommonUtils.StrToDate(replace);
                            long time = date.getTime();
                            if (time <time1 && time > time1 - time0){
                                newEnt++;
                            }
                        }
                        String industryStr =(String)jsonObject.getJSONObject("ATTIBUTEMAP").get("INDUSTRY_CLASS");
                        if (!industryCountMap.containsKey(industryStr)){
                            industryCountMap.put(industryStr,1);
                        } else {
                            int count = (int)industryCountMap.get(industryStr);
                            industryCountMap.put(industryStr,++count);
                        }

                        String provinceStr = (String)jsonObject.getJSONObject("ATTIBUTEMAP").get("PROVINCE");
                        if (!provinceCountMap.containsKey(provinceStr)){
                            provinceCountMap.put(provinceStr,1);
                        } else {
                            int count =(int)provinceCountMap.get(provinceStr);
                            provinceCountMap.put(provinceStr,++count);
                        }
                    }
                }

                Set<Map.Entry<String, Integer>> inEntrySet = industryCountMap.entrySet();
                for (Map.Entry<String, Integer> entry:inEntrySet){

                    int value= (int)entry.getValue();
                    if(value > in){
                        in = value;
                        industry = entry.getKey() + "(" + value + ")";
                    }
                }


                Set<Map.Entry<String, Integer>> prEntrySet = provinceCountMap.entrySet();
                for (Map.Entry<String, Integer> entry:prEntrySet){
                    int value= (int)entry.getValue();
                    if(value > pri){
                        pri = value;
                        province = "" + entry.getKey();
                    }
                }


                for (int i = 0;i <linksList.size();i++) {
                    JSONObject jsonObject = (JSONObject) linksList.get(i);
                    String id = (String) jsonObject.get("ID");
                    if (id ==null || "".equals(id)){
                        continue;
                    } else if (id.contains("Serve__Person_Enterprise")){
                        personalCount++;
                    } else if (id.contains("Branch__Enterprise_Enterprise")){
                        branchCount++;
                    }

                }

            } catch (Exception e){
                e.printStackTrace();
                return null;
            }
        } else {
            return null;
        }
        resultMap.put("coreEntCount",coreEntCount);
        resultMap.put("capitalSum",new DecimalFormat("0.00").format(capitalSum));
        resultMap.put("newEnt",newEnt);
        resultMap.put("personalCount",personalCount);
        resultMap.put("branchCount",branchCount);
        resultMap.put("province",province);
        resultMap.put("industry",industry);
        return resultMap;
    }

    /**
     * 企业搜索网址过滤
     * @param array
     * @return
     */
    public static JSONArray getUpdateWEBURL(JSONArray array){

        if (array.size() < 0){
            return null;
        }

        for (int i = 0;i < array.size();i++){

            Map<String,Object> map =(Map<String,Object>)array.get(i);
            String value= (String)map.get("WEBURL");

            if ("".equals(value) || !value.contains("/")){
                  continue;
            } else {
                if (value.startsWith("http://") || value.startsWith("Http://") ){
                    String newValue = value.substring(7,value.length());

                    while (newValue.contains("/")){
                        int lastIndex = newValue.lastIndexOf("/");
                        newValue = newValue.substring(0, lastIndex);
                    }
                      map.put("WEBURL",newValue);
                }

            }
        }

        return array;

    }

    /**
     *  网络招聘按时间倒序排序
     * @param list
     * @return
     */
    public static List<Map<String,Object>> getRecruitmentInfoByFZPRH_LAESTUPDATEDesc(List<Map<String, Object>> list){

        if (list.size() > 0){
            for (int i = 1; i < list.size(); i++) {
                for (int j = 1; j < list.size() - i - 1; j++) {
                    Map<String, Object> tmp1 = list.get(j);
                    Map<String, Object> tmp2 = list.get(j + 1);
                    try {
                        Date parse1 = new SimpleDateFormat("yyyy-MM-dd").parse(tmp1.get("FZPRH_LAESTUPDATE").toString());
                        Date parse2 = new SimpleDateFormat("yyyy-MM-dd").parse(tmp2.get("FZPRH_LAESTUPDATE").toString());

                        if (parse1.getTime() < parse2.getTime()) {
                            Map<String, Object> temp = tmp1;
                            list.remove(j);
                            list.add(j, tmp2);
                            list.remove(j + 1);
                            list.add(j + 1, temp);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            return list;
        } else {
            return null;
        }

    }

    /**
     * 新闻过滤实体拼串entities
     * @param ostr
     * @return
     */
    public static String  getSplitString(String ostr){

        String  nstr = "";
        if(ostr == null){
            return nstr;
        }
        String[] splits = ostr.split(",");
        for (int i = 0;i < splits.length;i++){
            if(i == splits.length -1){
                String temp = splits[i];
                nstr += temp;
            } else {
                String temp = splits[i] + ";";
                nstr += temp;
            }
        }
        return nstr;

    }

    /**
     * 年报按年倒序
     * @param list
     * @return
     */
    public static List<Map<String,Object>> getEntSFCAnnReportRelatedInfoByNBYEARDesc(List<Map<String,Object>> list){

        for (int i = 0; i < list.size(); i++) {
            for (int j = 0; j < list.size() - i - 1; j++) {
                Map<String, Object> tmp1 = list.get(j);
                Map<String, Object> tmp2 = list.get(j + 1);
                int d1 = Integer.parseInt(tmp1.get("NBYEAR").toString());
                int d2 = Integer.parseInt(tmp2.get("NBYEAR").toString());
                if (d1 < d2) {
                    Map<String, Object> temp = tmp1;
                    list.remove(j);
                    list.add(j, tmp2);
                    list.remove(j + 1);
                    list.add(j + 1, temp);
                }
            }
        }
        return list;
    }


    /**
     * 总收入区间显示
     *
     * @param list
     * @return
     */
    public static String getAnnualInspectionInfoByVENDINC(List<Map<String, Object>> list) {

        /**获取最近时间的那条记录*/
        for (int i = 0; i < list.size(); i++) {
            for (int j = 0; j < list.size() - i - 1; j++) {
                Map<String, Object> tmp1 = list.get(j);
                Map<String, Object> tmp2 = list.get(j + 1);
                try {
                    Date parse1 = new SimpleDateFormat("yyyy-MM-dd").parse(tmp1.get("ANCHEDATE").toString());
                    Date parse2 = new SimpleDateFormat("yyyy-MM-dd").parse(tmp2.get("ANCHEDATE").toString());

                    if (parse1.getTime() < parse2.getTime()) {
                        Map<String, Object> temp = tmp1;
                        list.remove(j);
                        list.add(j, tmp2);
                        list.remove(j + 1);
                        list.add(j + 1, temp);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
        /**获最近一年总收入   计算区间*/
        String vendinc = list.get(0).get("VENDINC").toString();

        if (vendinc == null || "".equals(vendinc)) {//如果date 为null或空串  直接返回”-“；
            return "-";
        }
        String str = null;
        if (vendinc.contains(".")) {
            int index = vendinc.lastIndexOf(".");
            str = vendinc.substring(0, index);
        } else {
            str = vendinc;
        }

        int value = Integer.parseInt(str);
        if (value == 0) { //如果为0  直接返回”0“
            return "0";
        } else {
            if (value > 10000) {
                int[] maxInterval = {10000, 25000, 50000, 75000, 100000, 250000, 500000, 750000, 1000000, 2500000, 5000000, 7500000, 10000000};
                for (int i = 0; i < maxInterval.length; i++) {
                    if (value <= maxInterval[i]) {

                        return maxInterval[i - 1] / 10000 + "亿" + "-" + maxInterval[i] / 10000 + "亿";
                    }
                }

            } else {
                int[] interval = {0, 25, 50, 75, 100, 250, 500, 750, 1000, 2500, 5000, 7500, 10000};
                for (int i = 0; i < interval.length; i++) {
                    if (value <= interval[i]) {
                        if (value > 7500) {
                            return interval[i - 1] + "万" + "-" + interval[i] / 10000 + "亿";
                        }
                        return interval[i - 1] + "万" + "-" + interval[i] + "万";
                    }
                }
            }

        }

        return null;
    }


    /**
     * 主要管理人员性别修改，职务分类
     *
     * @param list
     * @return
     */
    public static List<Map<String, List<Map<String, Object>>>> updateManagerSEX(List<Map<String, Object>> list) {

        List<Map<String, List<Map<String, Object>>>> groupList = new ArrayList<Map<String, List<Map<String, Object>>>>();
        LinkedHashMap groupMap = new LinkedHashMap();
        for (Map<String, Object> personMap : list) {
            /**将性别男性,女性, 改为 男、女*/
            String sex = (String) personMap.get("SEX");
            if (sex == null || "".equals(sex)) {
                continue;
            } else {
                personMap.put("SEX", sex.equals("男性") ? "男" : "女");
            }
        }
        /**管理人员根据职务进行分组*/
        List<Map<String, Object>> dmapList = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> smapList = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> gmapList = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> omapList = new ArrayList<Map<String, Object>>();
        for (Map<String, Object> personMapGroup : list) {
            if (personMapGroup.get("POSITION").toString().equals("董事长")) {
                dmapList.add(personMapGroup);
                break;
            }
        }

        for (Map<String, Object> personMapGroup : list) {
            if (personMapGroup.get("POSITION").toString().contains("董事")) {
                if (personMapGroup.get("POSITION").toString().equals("董事长")){
                    continue;
                }
                dmapList.add(personMapGroup);
                continue;
            } else if (personMapGroup.get("POSITION").toString().contains("监事")) {
                smapList.add(personMapGroup);
                continue;
            } else if (personMapGroup.get("POSITION").toString().contains("经理")) {
                gmapList.add(personMapGroup);
                continue;
            } else {
                omapList.add(personMapGroup);
            }
        }
        groupMap.put("DIRECTORS", dmapList);
        groupMap.put("SUPERVISORS", smapList);
        groupMap.put("GMANAGERS", gmapList);
        groupMap.put("OTHER", omapList);

        groupList.add(groupMap);
        return groupList;

    }


    /**
     * 股东出资金额倒序
     *
     * @param list
     * @return
     */
    public static List<Map<String, Object>> getShareHolderInfoBySUBCONAMDesc(List<Map<String, Object>> list) {

        for (int i = 0; i < list.size(); i++) {
            for (int j = 0; j < list.size() - i - 1; j++) {
                Map<String, Object> tmp1 = list.get(j);
                Map<String, Object> tmp2 = list.get(j + 1);
                double d1 = Double.parseDouble(tmp1.get("SUBCONAM").toString());
                double d2 = Double.parseDouble(tmp2.get("SUBCONAM").toString());
                if (d1 < d2) {
                    Map<String, Object> temp = tmp1;
                    list.remove(j);
                    list.add(j, tmp2);
                    list.remove(j + 1);
                    list.add(j + 1, temp);
                }
            }
        }
        return list;
    }

//    /**
//     * 根据act分组
//     * @param list
//     * @return
//     */
//
//    public static List<Map<String, List<Map<String, Object>>>> getInfoByGroup(List<Map<String, Object>> list) {
//        List<Map<String, List<Map<String, Object>>>> groupList = new ArrayList<Map<String, List<Map<String, Object>>>>();
//        Map<String, List<Map<String, Object>>> groupMap = new HashMap<String, List<Map<String, Object>>>();
//        for (Map<String, Object> personMap : list) {
//            /**************根据act分组****************/
//            String act = (String) personMap.get("ACT");
//            if (act == null || "".equals(act)) {
//                continue;
//            }
//            if (!groupMap.containsKey(act)) {
//                List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
//                mapList.add(personMap);
//                groupMap.put(act, mapList);
//
//            } else {
//                List<Map<String, Object>> valueList = groupMap.get(act);
//                valueList.add(personMap);
//                groupMap.put(act, valueList);
//            }
//
//        }
//
//        groupList.add(groupMap);
//
//        return groupList;
//    }


//    HashMap<String, Object> countMap = new HashMap<String,Object>();
//    Set<String> strings = groupMap.keySet();
//    Iterator<String> iterator = strings.iterator();
//    while (iterator.hasNext()){
//        String key = iterator.next();
//
//        countMap.put(key,groupMap.get(key).size());
//
//    }
//
//    String reault = JSONEncoder.encode(countMap);
//    System.out.println(reault);

    /**
     * 获取ACT分8组数量
     * @param list
     * @return
     */
    public static LinkedHashMap<String, Object> getInfoByGroupCount(List<Map<String, Object>> list) {

        Map<String, List<Map<String, Object>>> groupMap = new LinkedHashMap<String, List<Map<String, Object>>>();
        LinkedHashMap<String, Object> countMap = new LinkedHashMap<String,Object>();
//        HashMap<String, Object> resultMap = new LinkedHashMap<String,Object>();
        List<Map<String, Object>> QYBGList = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> DWTZList = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> ZLZCList = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> SBZCList = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> RJCPList = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> ZZRZList = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> WZXXList = new ArrayList<Map<String, Object>>();
        List<Map<String, Object>> WFWGList = new ArrayList<Map<String, Object>>();

        for (Map<String, Object> personMap : list) {

            String act = (String) personMap.get("ACT");
            if (act == null || "".equals(act)) {
                continue;
            }

            if (act.equals("企业类型变更") || act.equals("住所变更") || act.equals("名称变更")
                    || act.equals("实收资本变更") || act.equals("法定代表人变更") || act.equals("注册资本(金)变更")
                    || act.equals("登记机关变更") || act.equals("经营场所变更") ) {

                QYBGList.add(personMap);

            } else if (act.equals("投资公司") || act.equals("投资者名称(姓名)变更") ) {
                DWTZList.add(personMap);
            } else if (act.equals("授权专利") || act.equals("申请专利") ) {
                ZLZCList.add(personMap);
            } else if (act.equals("注册商标") || act.equals("申请商标") ) {
                SBZCList.add(personMap);
            } else if (act.equals("登记作品著作权") || act.equals("登记软件产品") || act.equals("登记软件著作权") ) {
                RJCPList.add(personMap);
            } else if (act.equals("取消高新技术企业认证") ) {
                ZZRZList.add(personMap);
            } else if (act.equals("备案网站") ) {
                WZXXList.add(personMap);
            } else if (act.equals("失信涉案") || act.equals("涉案") || act.equals("登报公告") ) {
                WFWGList.add(personMap);
            }
        }

        groupMap.put("企业变更",QYBGList);
        groupMap.put("对外投资",DWTZList);
        groupMap.put("专利注册",ZLZCList);
        groupMap.put("商标注册",SBZCList);
        groupMap.put("软件产品",RJCPList);
        groupMap.put("资质认证",ZZRZList);
        groupMap.put("网站信息",WZXXList);
        groupMap.put("违法违规",WFWGList);

        Set<String> groupStrings = groupMap.keySet();
        Iterator<String> iterator = groupStrings.iterator();
        while (iterator.hasNext()){
            String key = iterator.next();
            countMap.put(key,groupMap.get(key).size());

        }

        return countMap;
    }

    /**
     * 每年act数量统计
     * @param list
     * @return
     */

    public static Map<String, LinkedHashMap<String, Object>> getInfoByYearGroupCount(List<Map<String, Object>> list) {

        Map<String, List<Map<String, Object>>> groupMap = new LinkedHashMap<String, List<Map<String, Object>>>();
        Map<String, LinkedHashMap<String, Object>> resultMap = new LinkedHashMap<String, LinkedHashMap<String, Object>>();


        for (Map<String, Object> personMap : list) {

            String date = (String) personMap.get("MONTH");
            if (date == null || "".equals(date)){
                continue;
            }
            String yearKey = date.substring(0, 4);

            if (!groupMap.containsKey(yearKey)){

                List<Map<String, Object>> mapList = new ArrayList<Map<String, Object>>();
                mapList.add(personMap);
                groupMap.put(yearKey, mapList);

            } else {
                List<Map<String, Object>> valueList = groupMap.get(yearKey);
                valueList.add(personMap);
                groupMap.put(yearKey, valueList);
            }



        }


        Set<Map.Entry<String, List<Map<String, Object>>>> entries = groupMap.entrySet();

        Iterator<Map.Entry<String, List<Map<String, Object>>>> iterator = entries.iterator();
        while (iterator.hasNext()){
        	LinkedHashMap<String, Object> countMap = new LinkedHashMap<String,Object>();
            List<Map<String, Object>> QYBGList = new ArrayList<Map<String, Object>>();
            List<Map<String, Object>> DWTZList = new ArrayList<Map<String, Object>>();
            List<Map<String, Object>> ZLZCList = new ArrayList<Map<String, Object>>();
            List<Map<String, Object>> SBZCList = new ArrayList<Map<String, Object>>();
            List<Map<String, Object>> RJCPList = new ArrayList<Map<String, Object>>();
            List<Map<String, Object>> ZZRZList = new ArrayList<Map<String, Object>>();
            List<Map<String, Object>> WZXXList = new ArrayList<Map<String, Object>>();
            List<Map<String, Object>> WFWGList = new ArrayList<Map<String, Object>>();
            Map.Entry<String, List<Map<String, Object>>> next = iterator.next();
            String key = next.getKey();
            List<Map<String, Object>> valueList = next.getValue();
            for (Map<String, Object> lists : valueList) {

                String act = (String) lists.get("ACT");
                if (act == null || "".equals(act)) {
                    continue;
                }

                if (act.equals("企业类型变更") || act.equals("住所变更") || act.equals("名称变更")
                        || act.equals("实收资本变更") || act.equals("法定代表人变更") || act.equals("注册资本(金)变更")
                        || act.equals("登记机关变更") || act.equals("经营场所变更") ) {

                    QYBGList.add(lists);

                } else if (act.equals("投资公司") || act.equals("投资者名称(姓名)变更") ) {
                    DWTZList.add(lists);
                } else if (act.equals("授权专利") || act.equals("申请专利") ) {
                    ZLZCList.add(lists);
                } else if (act.equals("注册商标") || act.equals("申请商标") ) {
                    SBZCList.add(lists);
                } else if (act.equals("登记作品著作权") || act.equals("登记软件产品") || act.equals("登记软件著作权") ) {
                    RJCPList.add(lists);
                } else if (act.equals("取消高新技术企业认证") ) {
                    ZZRZList.add(lists);
                } else if (act.equals("备案网站") ) {
                    WZXXList.add(lists);
                } else if (act.equals("失信涉案") || act.equals("涉案") || act.equals("登报公告") ) {
                    WFWGList.add(lists);
                }
            }

            countMap.put("企业变更",QYBGList.size());
            countMap.put("对外投资",DWTZList.size());
            countMap.put("专利注册",ZLZCList.size());
            countMap.put("商标注册",SBZCList.size());
            countMap.put("软件产品",RJCPList.size());
            countMap.put("资质认证",ZZRZList.size());
            countMap.put("网站信息",WZXXList.size());
            countMap.put("违法违规",WFWGList.size());

            resultMap.put(key,countMap);


        }

        return resultMap;

    }

    /**
     * 处理html标签和空格
     * @param list
     * @return
     */

    public static JSONArray replaceHtml(JSONArray list){

        if (list.size() < 0){
            return null;
        }

        for (int i = 0;i < list.size();i++){
            Map<String,Object> resutmap = (Map<String,Object>)list.get(i);
            String fzprh_positiondesc = (String)resutmap.get("FZPRH_POSITIONDESC");
            String regEx_html = "<[^>]+>"; // 定义HTML标签的正则表达式
            Pattern p_html = Pattern.compile(regEx_html, Pattern.CASE_INSENSITIVE);
            Matcher m_html = p_html.matcher(fzprh_positiondesc);
            fzprh_positiondesc = m_html.replaceAll(""); // 过滤html标签

            String regEx_space = "\\s*|\t|\r|\n";//定义空格回车换行符
            Pattern p_space = Pattern.compile(regEx_space, Pattern.CASE_INSENSITIVE);
            Matcher m_space = p_space.matcher(fzprh_positiondesc);
            fzprh_positiondesc = m_space.replaceAll("");
            resutmap.put("FZPRH_POSITIONDESC",fzprh_positiondesc);

        }

        return list;
    }
}
